Page({
  data: {
    location: "",
    result: []
  },
  // 获取输入位置
  inp: function (event) {
    var val = event.detail.value
    this.setData({
      location: val
    })
  },
  taptap: function () {
    // 判断输入框是否已输入城市
    if (this.data.location.length == 0) {
      return;
    }
    // 将输入城市进行记录
    var city = this.data.location;
    // 将输入城市传递给接口，并进行调用
    this.getweather(city);
  },
  getweather: function (value) {
    var that = this;
    // 天气API
    wx.request({
      url: 'http://www.tianqiapi.com/api?version=v1',
      data: {
        appid: "97725274 ",
        appsecret: "4mMl5cqA",
        city: value
      },
      success: function (res) {
        console.log(res)
        that.setData({
          result: res.data.data
        })
        console.log(that.data.result)
      },
      false: function (err) {
        console.log(err)
      }
    })
  }
})